//初始化加载折线图和表格
$(document).ready(function () {
	siteKey = $("#siteKey").val();
	type = $("#hdtype").val();
	if(siteKey=="" || type==""){
		var str = "<div class='em100 whitediv' id='zhanwushuju'><div class='em25'></div><div class='backyellow'>&nbsp;&nbsp;暂无数据！请选择场所</div></div>"
		$("#myForm .widthall .chartdiv").children("div[id!='zhanwushuju']").hide();
		$("#myForm .widthall .xiangxidiv").children("div[id!='zhanwushuju']").hide();
		$("#myForm .widthall .chartdiv").html(str);
		$("#myForm .widthall .xiangxidiv").html(str);
	}else{
		getspan('day_7');
	}
})

//时间段时间控件
$( function () {
	var endDate=new Date();//当前时间
	endDate=endDate.getFullYear()+"-"+(endDate.getMonth()+1)+"-"+endDate.getDate();
	var startDate=(new Date());
	startDate.setDate(startDate.getDate()-30);//前一个月时间
	startDate=startDate.getFullYear()+"-"+(startDate.getMonth()+1)+"-"+startDate.getDate();
	siteKey = $("siteKey").val();
 	if(siteKey!=""){
	    var dateObj = {
	        theme: 'ta', // 日期选择器TA主题
	        autoCommit: true, //自动提交，完成日期初始化，以及图表的展示拉取
	        isTodayValid: true,
	        startDate: startDate,
	        endDate: endDate,
	        needCompare: true,
	        startCompareDate: '',
	        endCompareDate: '',
	        singleCompare: false,
	        defaultText: ' 至 ',
	        autoSubmit: false,
	        shortOpr: false,
	        target: 'datePicker',
	        calendars: 2,
	        inputTrigger: 'input_trigger',
	        compareCheckboxId: false,
	        success: function (obj) {
	            if (($("#txtspan").val().split("_"))[1] == "0" || $("#needCompare").val() == "1")//处于如期选择框时
	            {
	                loadChart($("#hdtype").val());
	            }
	        }
	    };
	    new pickerDateRange("date", dateObj)
 	}
})


//加载折线图表取XY轴
function  getXY(result) {
	var xsisRe="";
	var dataRe="";
	var dataRe1="";
	var dataRe2="";
	for(var i=0;i<result.length;i++){
		xsisRe=xsisRe + result[i].datatime+",";
		indexNamefiled = "customerNum";
		dataRe = dataRe+((getObjectVlue(result[i],indexNamefiled))==null?0:(getObjectVlue(result[i],indexNamefiled)))+",";
		indexNamefiled1 = "memNum";
		dataRe1 = dataRe1+((getObjectVlue(result[i],indexNamefiled1))==null?0:(getObjectVlue(result[i],indexNamefiled1)))+",";
		indexNamefiled2 = "memNumPro";
		dataRe2 = dataRe2+((getObjectVlue(result[i],indexNamefiled2))==null?0:(getObjectVlue(result[i],indexNamefiled2)))+",";
	}
	xsisRe=xsisRe.substring(0,xsisRe.length-1);
	dataRe=dataRe.substring(0,dataRe.length-1);
	dataRe1=dataRe1.substring(0,dataRe1.length-1);
	dataRe2=dataRe2.substring(0,dataRe2.length-1);
	var result =new Array();
	result.push(xsisRe);
	result.push(dataRe);
	result.push(dataRe1);
	result.push(dataRe2);
	return result
}

//加载折线图表
 function loadChart(type) {
	 showLoading();
     var data = [];
     var xsis = [];
     var from = $('#startDate').val();
     var to = $('#endDate').val();
     var siteId= $("#siteKey").val();
     var tubiao = "tubiao1";
     var span = $("#txtspan").val();
     shijianCss(span);
     var myChart = echarts.init(document.getElementById(tubiao));
   	$.ajax( {
   		type : "GET",
   		contentType:"application/json",
   		dataType : 'json',
   		url: "getSquareMemberData",
   		data: { from: from, to: to,span: span, siteId: siteId },
   		async: true,
   		success : function(ret) {
   			var width = $("#tubiao1").width();
			var height = $("#tubiao1").height();
			var titleOffens = width*7.6/100;
			var dataZoomY = height*(1-19/100);
			var toolboxX = width*80/100;
			var legendY = height*4/100;
			var toolboxY = height*4/100;
			//获取当前时间
			var date = new Date;
			var today = timeFormat(date);
			//保存图片的名称
			var toolboxName = $("#titles").val()+'-趋势分析'+today;
   			var result = ret.result;//返回数据集
   			var tubiaoDate=ret.loadTable;//图表一数据
   			var stadubiao = ret.stadubiao;
   			var endtubiao = ret.endtubiao;
   			var siteN = ret.siteN;
			var titContext="数据说明：会员综合分析"+"\n"
					+"时间范围："+stadubiao+(endtubiao==null?'':"~"+endtubiao)+"\n"
					+"场所名称："+siteN+"\n"
					+"指标名称：顾客数（人）&到达会员人数（人）";
			var biaogeshuoming = "数据说明：会员综合分析"+"<br/>"
					+"时间范围："+stadubiao+(endtubiao==null?'':"~"+endtubiao)+"<br/>"
					+"场所名称："+siteN+"<br/>"
					+"指标名称：顾客数（人）&到达会员人数（人）";
					
			$("#biaogeshuoming").html(biaogeshuoming);
   			var resultXY=getXY(result);
			xsisRe=resultXY[0];
			
			dataRe=resultXY[1];	   
			dataRe1=resultXY[2];
			dataRe2=resultXY[3];	  		
   			
			xsis = xsisRe.split(",");
			var titName = "['顾客数','到达会员人数']";
   			titName= eval(titName);

			/**
   			 * 横坐标只有一个值时显示为柱状图，柱状宽度最大为40
   			 */
   			var lineType = 'bar';
   			if(xsis.length ==1){
   				lineType = 'bar';
   			}else{
   				lineType = 'bar';
   			}
			//获取当前时间
			var date = new Date;
			var today =  timeFormat(date);
			//保存图片的名称
			var toolboxName = $("#titles").val()+'-趋势分析'+today;
   			var barMaxWidthn = 40;
   			var markLinePrecision = 0;
   			data = eval("[{name:'顾客数',type:lineType,smooth: smoothType,barMaxWidth:barMaxWidthn,itemStyle:{ normal:{ color:'#feab41',label:{show:"+getShow(xsis)+",position:'top'}}},data:[" +dataRe + "]},{name:'到达会员人数',type:lineType,yAxisIndex: 1,smooth: smoothType,barMaxWidth:barMaxWidthn,itemStyle:{ normal:{color:'#00BFFF',label:{show:"+getShow(xsis)+",position:'top'}}},data:[" +dataRe1 + "]}]");	

   			var  option = {
			title : {
 		      text: titContext,
 		      y:'bottom',
 		      x:titleOffens,
 		      textStyle:{
 		       	fontSize: 12,
   		        color: '#666',
				fontFamily:'微软雅黑, 兰亭细黑, 宋体',
   		        fontWeight:'normal'
 		    	}		
 		    },
 		   tooltip: {
   				trigger: 'axis',
   			},
			legend: {
				data:titName,
				y:legendY
				},
			dataZoom: {
   		        show: true,
   		        y:dataZoomY 
   		    },
			grid:{
   				x:'7.6%',
				x2:'7.6%',
   				y:'11%',
   				y2:'27%',
   				borderWidth: gridBorderWidth,
				borderColor:'#EEE'
   			},
		    toolbox: {
		        show : true,
		        feature : {
		            mark : {show: true},
		            magicType : {show: true, type: [ 'stack']},
		            restore : {show: true},
		            saveAsImage : {show: true,name:toolboxName}
		        },
				x:toolboxX,
				y:toolboxY
		    },
		    calculable : true,
		    xAxis : [
		        {
		        	name : '',
		        	boundaryGap: true,//两端空白策略
		        	allowDecimals :true,//使用小数
		            type : 'category',
		            splitLine: {show: xAxisSplitLine,
					lineStyle:{
							 color: ['#EEE'],
							
						}},//不显示竖线
		            splitArea:{
						show:xAxissplitArea,
						areaStyle:{
								color: [
						        'rgba(250,250,250,0.1)',
						        'rgba(200,200,200,0.1)']
							}
					},
		            data : xsis,
		            axisTick:{
						show:true,
						interval:0
					}
		        }
		    ],
		    yAxis : [
		        {
					axisLabel:{
							formatter: function (value) {
			            		if(value > 10000){
			            			return (value/10000)+'万';
			            		}else{
			            			return value + '';
			            		}
							}
						},
		        	splitLine: {
						show: yAxisSplitLine,
						lineStyle:{
							 color: ['#EEE'],
							
						}},//不显示竖线
		        	splitArea:{
						show:yAxissplitArea,
						areaStyle:{
							color: [
					        'rgba(250,250,250,0.1)',
					        'rgba(200,200,200,0.1)']
						}
					},
		        	name : '顾客数（人）',
		            type : 'value',
					axisLine:{
						lineStyle:{
							 color: '#FFA500',
							 width: 2,
							 type: 'solid'
						}
					}
		        },
				{
					axisLabel:{
							formatter: function (value) {
			            		if(value > 10000){
			            			return (value/10000)+'万';
			            		}else{
			            			return value + '';
			            		}
							}
						},
					splitLine: {
						show: yAxisSplitLine,
						lineStyle:{
							 color: ['#EEE'],
							
						}},//不显示竖线
		        	splitArea:{
						show:yAxissplitArea,
						areaStyle:{
							color: [
					        'rgba(250,250,250,0.1)',
					        'rgba(200,200,200,0.1)']
						}
					},
		            type : 'value',
		            name : '到达会员人数（人）',
		            axisLabel : {
//	                	formatter: '占比（%）'
            		},
					axisLine:{
						lineStyle:{
							 color: '#00BFFF',
							 width: 2,
							 type: 'solid'
						}
					}
        		}
		    ],
		    series : data
		};
   			//改变窗口大小使图标自适应窗口显示
   			window.onresize = function () {
   				myChart.resize();
   			}
   			//加载折线图
   			myChart.setOption(option);
   			//加载表格
   			loadChartTable(tubiaoDate);
   			hideLoading();
			
			var peiArrFenbu = ret.peiArrFenbu;
			loadpeiArrFenbuGraph(peiArrFenbu,stadubiao,endtubiao,siteN);
			
			var memberArrveSex = ret.memberArrveSex;
			loadpeiArrSexGraph(memberArrveSex,stadubiao,endtubiao,siteN);
			
			var memberArrveAge = ret.memberArrveAge;
			loadpeiArrOldGraph(memberArrveAge,stadubiao,endtubiao,siteN);
			
			
			
			var peiMemberFenbu = ret.peiMemberFenbu;
			loadpeiMemFenbuGraph(peiMemberFenbu,stadubiao,endtubiao,siteN);
			
			var memberArrveSexAll = ret.memberArrveSexAll;
			loadpeiMemSexGraph(memberArrveSexAll,stadubiao,endtubiao,siteN);
			
			var memberArrveAgeAll = ret.memberArrveAgeAll;
			loadpeiMemOldGraph(memberArrveAgeAll,stadubiao,endtubiao,siteN);
			
			
			
			
			
			
			var retReportGraphData = ret.retReportGraphData;
			loadReportGraphDataChart(retReportGraphData,stadubiao,endtubiao,siteN);
			
			
   		},
		error : function(mm, a, b, c, d, e) {
				hideLoading();
				alert("服务器好像开小差了，刷新一下试试吧！");
			}
   	})
}

//
function getStartEndComeXY(result){
	var xsisRe="";
	var dataRe="";
	var dataRe1="";
	for(var i=0;i<result.length;i++){
		xsisRe = xsisRe + result[i].time+",";
		indexNamefiled = "innum";
		dataRe = dataRe+((getObjectVlue(result[i],indexNamefiled))==null?0:(getObjectVlue(result[i],indexNamefiled)))+",";
		indexNamefiled1 = "outnum";
		dataRe1 = dataRe1+((getObjectVlue(result[i],indexNamefiled1))==null?0:(getObjectVlue(result[i],indexNamefiled1)))+",";
	}
	xsisRe=xsisRe.substring(0,xsisRe.length-1);
	dataRe=dataRe.substring(0,dataRe.length-1);
	dataRe1=dataRe1.substring(0,dataRe1.length-1);
	var result =new Array();
	result.push(xsisRe);
	result.push(dataRe);
	result.push(dataRe1);
	return result
}

//加载折线图表
 function loadReportGraphDataChart(retReportGraphData,stadubiao,endtubiao,siteN) {
   	
	var yezhu = 12;
	var shangye = 13;
	var app = 13;
	
	var width = $("#historyWeatherGraph").width();
	var height = $("#historyWeatherGraph").height();
	titContext = "人数分布";
	var fontwithd = 18*4;
	var fontheight = 18;
	var titleX = (width - fontwithd)/2;
	var titleY = (height - fontheight)/2;
	var myChart = echarts.init(document.getElementById("historyWeatherGraph"));
	var option = {
			title : {
			  show:false,
		      text: titContext,
		      y:titleY,
		      x:titleX,
		      textStyle:{
		        fontSize: 18,
			        color: '#666',
				fontFamily:'微软雅黑, 兰亭细黑, 宋体',
			        fontWeight:'normal'
		    	}
			},
			legend: {
				show:false,
		        orient : 'horizontal',
		        x : 'center',
				y : 'bottom',
		        data:['到达会员','未到达会员']
    		},
		    tooltip: {
				trigger: 'item',
			},
	    	calculable : false,
		    series : [
		        {
		            type:'pie',
		            radius : '55%',
		            center: ['50%', '50%'],
					itemStyle : {
		                  normal : {
		                      label : {
		                          show : true
		                      },
		                      labelLine : {
		                          show : true
		                      }
		                  },
		              },
		            data:[
			                {value:yezhu, name:'业主入会'},
			                {value:shangye, name:'商业入会'},
							{value:app, name:'App入会'}
			            ]
		        }
		    ]
	};
	//改变窗口大小使图标自适应窗口显示
	window.onresize = function () {
	myChart.resize();
	}
	myChart.setOption(option);
}


function getWeek(dateStr){
	 arys1=dateStr.split('-'); 
	 var ssdate=new Date(arys1[0],parseInt(arys1[1]-1),arys1[2]);   
	 if(ssdate.getDay()==0){
		 return "星期天"
	 }else if(ssdate.getDay()==1){
		 return "星期一"
	 }else if(ssdate.getDay()==2){
		 return "星期二"
	 }else if(ssdate.getDay()==3){
		 return "星期三"
	 }else if(ssdate.getDay()==4){
		 return "星期四"
	 }else if(ssdate.getDay()==5){
		 return "星期五"
	 }else if(ssdate.getDay()==6){
		 return "星期六" 
	 }
}

function loadChartTable(tubiaoDate){
	$("#hdtable").val(tubiaoDate);
	showtable(1);
}

function loadpeiArrFenbuGraph(peiArrFenbu,stadubiao,endtubiao,siteN){
	
	var arrMemberNum =parseInt(peiArrFenbu.arrMemberNum);
	var noArrMemberNum = parseInt(peiArrFenbu.noArrMemberNum);
	
	var total = arrMemberNum+noArrMemberNum;
	var tolalper = (parseFloat((arrMemberNum/total*100).toFixed(2))+parseFloat((noArrMemberNum/total*100).toFixed(2)));
	var totaldis = parseFloat(tolalper) - 100; 
	
	var width = $("#peiArrFenbu").width();
	var height = $("#peiArrFenbu").height();
	titContext = "人数分布";
	var fontwithd = 18*4;
	var fontheight = 18;
	var titleX = (width - fontwithd)/2;
	var titleY = (height - fontheight)/2;
	var myChart = echarts.init(document.getElementById("peiArrFenbu"));
	var option = {
			title : {
		      text: titContext,
		      y:titleY,
		      x:titleX,
		      textStyle:{
		        fontSize: 18,
			        color: '#666',
				fontFamily:'微软雅黑, 兰亭细黑, 宋体',
			        fontWeight:'normal'
		    	}
			},
			legend: {
		        orient : 'horizontal',
		        x : 'center',
				y : 'bottom',
		        data:['到达会员','未到达会员']
    		},
		    tooltip: {
				trigger: 'item',
				formatter: function(params, ticket, callback){
					console.log(params);
					var b = params[1];
					var c = params[2];
					var d =	params[3];
					var f = params[7];
					if(f==1){
						d = (parseFloat(d) - totaldis).toFixed(2);
					}
					return b+":"+c+"("+d+"%)";
				}
			},
	    	calculable : false,
		    series : [
		        {
		            type:'pie',
		            radius : ['45%', '70%'],
		            center: ['50%', '50%'],
					itemStyle : {
		                  normal : {
		                      label : {
		                          show : true
		                      },
		                      labelLine : {
		                          show : true
		                      }
		                  },
		              },
		            data:[
			                {value:arrMemberNum, name:'到达会员'},
			                {value:noArrMemberNum, name:'未到达会员'}
			            ]
		        }
		    ]
	};
	//改变窗口大小使图标自适应窗口显示
	window.onresize = function () {
	myChart.resize();
	}
	myChart.setOption(option);
 }
 
 
function loadpeiArrSexGraph(memberArrveSex,stadubiao,endtubiao,siteN){
	
	var man = memberArrveSex.man;
	var woman = memberArrveSex.woman;
	
	var total = man+woman;
	var tolalper = (parseFloat((man/total*100).toFixed(2))+parseFloat((woman/total*100).toFixed(2)));
	var totaldis = parseFloat(tolalper) - 100; 
	
	var width = $("#peiArrSex").width();
	var height = $("#peiArrSex").height();
	titContext = "性别比例";
	var fontwithd = 18*4;
	var fontheight = 18;
	var titleX = (width - fontwithd)/2;
	var titleY = (height - fontheight)/2;
	var myChart = echarts.init(document.getElementById("peiArrSex"));
	var option = {
			title : {
		      text: titContext,
		      y:titleY,
		      x:titleX,
		      textStyle:{
		        fontSize: 18,
			        color: '#666',
				fontFamily:'微软雅黑, 兰亭细黑, 宋体',
			        fontWeight:'normal'
		    	}		
			},
			legend: {
		        orient : 'horizontal',
		        x : 'center',
				y : 'bottom',
		        data:['男','女']
    		},
		    tooltip: {
				trigger: 'item',
				formatter: function(params, ticket, callback){
					console.log(params);
					var b = params[1];
					var c = params[2];
					var d =	params[3];
					var f = params[7];
					if(f==1){
						d = (parseFloat(d) - totaldis).toFixed(2);
					}
					return b+":"+c+"("+d+"%)";
				}
			},
	    	calculable : false,
		    series : [
		        {
		            type:'pie',
		            radius : ['45%', '70%'],
		            center: ['50%', '50%'],
					itemStyle : {
		                  normal : {
		                      label : {
		                          show : true
		                      },
		                      labelLine : {
		                          show : true
		                      }
		                  },
		              },
		            data:[
			                {value:man, name:'男'},
			                {value:woman, name:'女'},
			            ]
		        }
		    ]
	};
	//改变窗口大小使图标自适应窗口显示
	window.onresize = function () {
	myChart.resize();
	}
	myChart.setOption(option);
 } 
 
 function loadpeiArrOldGraph(memberArrveAge,stadubiao,endtubiao,siteN){
 	
	var sixteenLow = memberArrveAge.sixteenLow;
	var sixteenToTwentyFive = memberArrveAge.sixteenToTwentyFive;
	var TwentySixThirtyFive = memberArrveAge.TwentySixThirtyFive;
	var ThirtySixToFortyFive = memberArrveAge.ThirtySixToFortyFive;
	var FortyFiveUp = memberArrveAge.FortyFiveUp;
	
	var total = sixteenLow+sixteenToTwentyFive+TwentySixThirtyFive+ThirtySixToFortyFive+FortyFiveUp;
	var tolalper = (parseFloat((sixteenLow/total*100).toFixed(2))+parseFloat((sixteenToTwentyFive/total*100).toFixed(2))+parseFloat((TwentySixThirtyFive/total*100).toFixed(2))+parseFloat((ThirtySixToFortyFive/total*100).toFixed(2))+parseFloat((FortyFiveUp/total*100).toFixed(2)));
	var totaldis = parseFloat(tolalper) - 100; 
	
	var width = $("#peiArrOld").width();
	var height = $("#peiArrOld").height();
	titContext = "年龄分布";
	var fontwithd = 18*4;
	var fontheight = 18;
	var titleX = (width - fontwithd)/2;
	var titleY = (height - fontheight)/2;
	var myChart = echarts.init(document.getElementById("peiArrOld"));
	var option = {
			title : {
		      text: titContext,
		      y:titleY,
		      x:titleX,
		      textStyle:{
		        fontSize: 18,
			        color: '#666',
				fontFamily:'微软雅黑, 兰亭细黑, 宋体',
			        fontWeight:'normal'
		    	}		
			},
			legend: {
		        orient : 'horizontal',
		        x : 'center',
				y : 'bottom',
		        data:['16以下','16-25','26-35','36-45','45以上']
    		},
		    tooltip: {
				trigger: 'item',
				formatter: function(params, ticket, callback){
					console.log(params);
					var b = params[1];
					var c = params[2];
					var d =	params[3];
					var f = params[7];
					if(f==1){
						d = (parseFloat(d) - totaldis).toFixed(2);
					}
					return b+":"+c+"("+d+"%)";
				}
			},
	    	calculable : false,
		    series : [
		        {
		            type:'pie',
		            radius : ['45%', '70%'],
		            center: ['50%', '50%'],
					itemStyle : {
		                  normal : {
		                      label : {
		                          show : true
		                      },
		                      labelLine : {
		                          show : true
		                      }
		                  },
		              },
		            data:[
			                {value:sixteenLow, name:'16以下'},
			                {value:sixteenToTwentyFive, name:'16-25'},
			                {value:TwentySixThirtyFive, name:'26-35'},
			                {value:ThirtySixToFortyFive, name:'36-45'},
			                {value:FortyFiveUp, name:'45以上'},
			            ]
		        }
		    ]
	};
	//改变窗口大小使图标自适应窗口显示
	window.onresize = function () {
	myChart.resize();
	}
	myChart.setOption(option);
 } 
 
  function loadpeiMemFenbuGraph(peiMemberFenbu,stadubiao,endtubiao,siteN){
  	
	var memNumNum = peiMemberFenbu.memNumNum;
	var notMemNumNum = peiMemberFenbu.notMemNumNum;
	
	var total = memNumNum+notMemNumNum;
	var tolalper = (parseFloat((memNumNum/total*100).toFixed(2))+parseFloat((notMemNumNum/total*100).toFixed(2)));
	var totaldis = parseFloat(tolalper) - 100; 
	
	var width = $("#peiMemFenbu").width();
	var height = $("#peiMemFenbu").height();
	titContext = "人数分布";
	var fontwithd = 18*4;
	var fontheight = 18;
	var titleX = (width - fontwithd)/2;
	var titleY = (height - fontheight)/2;
	var myChart = echarts.init(document.getElementById("peiMemFenbu"));
	var option = {
			title : {
		      text: titContext,
		      y:titleY,
		      x:titleX,
		      textStyle:{
		        fontSize: 18,
			        color: '#666',
				fontFamily:'微软雅黑, 兰亭细黑, 宋体',
			        fontWeight:'normal'
		    	}
			},
			legend: {
		        orient : 'horizontal',
		        x : 'center',
				y : 'bottom',
		        data:['会员人数','非会员人数']
    		},
		    tooltip: {
				trigger: 'item',
				formatter: function(params, ticket, callback){
					console.log(params);
					var b = params[1];
					var c = params[2];
					var d =	params[3];
					var f = params[7];
					if(f==1){
						d = (parseFloat(d) - totaldis).toFixed(2);
					}
					return b+":"+c+"("+d+"%)";
				}
			},
	    	calculable : false,
		    series : [
		        {
		            type:'pie',
		            radius : ['45%', '70%'],
		            center: ['50%', '50%'],
					itemStyle : {
		                  normal : {
		                      label : {
		                          show : true
		                      },
		                      labelLine : {
		                          show : true
		                      }
		                  },
		              },
		            data:[
			                {value:memNumNum, name:'会员人数'},
			                {value:notMemNumNum, name:'非会员人数'}
			            ]
		        }
		    ]
	};
	//改变窗口大小使图标自适应窗口显示
	window.onresize = function () {
	myChart.resize();
	}
	myChart.setOption(option);
 } 
 
 
   function loadpeiMemSexGraph(memberArrveSexAll,stadubiao,endtubiao,siteN){
  	
	var man = memberArrveSexAll.man;
	var woman = memberArrveSexAll.woman;
	
	var total = man+woman;
	var tolalper = (parseFloat((man/total*100).toFixed(2))+parseFloat((woman/total*100).toFixed(2)));
	var totaldis = parseFloat(tolalper) - 100; 
	
	var width = $("#peiMemSex").width();
	var height = $("#peiMemSex").height();
	titContext = "性别比例";
	var fontwithd = 18*4;
	var fontheight = 18;
	var titleX = (width - fontwithd)/2;
	var titleY = (height - fontheight)/2;
	var myChart = echarts.init(document.getElementById("peiMemSex"));
	var option = {
			title : {
		      text: titContext,
		      y:titleY,
		      x:titleX,
		      textStyle:{
		        fontSize: 18,
			        color: '#666',
				fontFamily:'微软雅黑, 兰亭细黑, 宋体',
			        fontWeight:'normal'
		    	}		
			},
			legend: {
		        orient : 'horizontal',
		        x : 'center',
				y : 'bottom',
		        data:['男','女']
    		},
		    tooltip: {
				trigger: 'item',
				formatter: function(params, ticket, callback){
					console.log(params);
					var b = params[1];
					var c = params[2];
					var d =	params[3];
					var f = params[7];
					if(f==1){
						d = (parseFloat(d) - totaldis).toFixed(2);
					}
					return b+":"+c+"("+d+"%)";
				}
			},
	    	calculable : false,
		    series : [
		        {
		            type:'pie',
		            radius : ['45%', '70%'],
		            center: ['50%', '50%'],
					itemStyle : {
		                  normal : {
		                      label : {
		                          show : true
		                      },
		                      labelLine : {
		                          show : true
		                      }
		                  },
		              },
		            data:[
			                {value:man, name:'男'},
			                {value:woman, name:'女'},
			            ]
		        }
		    ]
	};
	//改变窗口大小使图标自适应窗口显示
	window.onresize = function () {
	myChart.resize();
	}
	myChart.setOption(option);
 } 
 
   function loadpeiMemOldGraph(memberArrveAgeAll,stadubiao,endtubiao,siteN){
  	
	var sixteenLow = memberArrveAgeAll.sixteenLow;
	var sixteenToTwentyFive = memberArrveAgeAll.sixteenToTwentyFive;
	var TwentySixThirtyFive = memberArrveAgeAll.TwentySixThirtyFive;
	var ThirtySixToFortyFive = memberArrveAgeAll.ThirtySixToFortyFive;
	var FortyFiveUp = memberArrveAgeAll.FortyFiveUp;
	
	var total = sixteenLow+sixteenToTwentyFive+TwentySixThirtyFive+ThirtySixToFortyFive+FortyFiveUp;
	var tolalper = (parseFloat((sixteenLow/total*100).toFixed(2))+parseFloat((sixteenToTwentyFive/total*100).toFixed(2))+parseFloat((TwentySixThirtyFive/total*100).toFixed(2))+parseFloat((ThirtySixToFortyFive/total*100).toFixed(2))+parseFloat((FortyFiveUp/total*100).toFixed(2)));
	var totaldis = parseFloat(tolalper) - 100; 
	
	var width = $("#peiMemOld").width();
	var height = $("#peiMemOld").height();
	titContext = "年龄分布";
	var fontwithd = 18*4;
	var fontheight = 18;
	var titleX = (width - fontwithd)/2;
	var titleY = (height - fontheight)/2;
	var myChart = echarts.init(document.getElementById("peiMemOld"));
	var option = {
			title : {
		      text: titContext,
		      y:titleY,
		      x:titleX,
		      textStyle:{
		        fontSize: 18,
			        color: '#666',
				fontFamily:'微软雅黑, 兰亭细黑, 宋体',
			        fontWeight:'normal'
		    	}		
			},
			legend: {
		        orient : 'horizontal',
		        x : 'center',
				y : 'bottom',
		        data:['16以下','16-25','26-35','36-45','45以上']
    		},
		    tooltip: {
				trigger: 'item',
				formatter: function(params, ticket, callback){
					console.log(params);
					var b = params[1];
					var c = params[2];
					var d =	params[3];
					var f = params[7];
					if(f==1){
						d = (parseFloat(d) - totaldis).toFixed(2);
					}
					return b+":"+c+"("+d+"%)";
				}
			},
	    	calculable : false,
		    series : [
		        {
		            type:'pie',
		            radius : ['45%', '70%'],
		            center: ['50%', '50%'],
					itemStyle : {
		                  normal : {
		                      label : {
		                          show : true
		                      },
		                      labelLine : {
		                          show : true
		                      }
		                  },
		              },
		            data:[
			                {value:sixteenLow, name:'16以下'},
			                {value:sixteenToTwentyFive, name:'16-25'},
			                {value:TwentySixThirtyFive, name:'26-35'},
			                {value:ThirtySixToFortyFive, name:'36-45'},
			                {value:FortyFiveUp, name:'45以上'},
			            ]
		        }
		    ]
	};
	//改变窗口大小使图标自适应窗口显示
	window.onresize = function () {
	myChart.resize();
	}
	myChart.setOption(option);
 } 
